package Demo4;

import java.util.Arrays;

/**
 * @author ：陈奕安（3048279304@qq.com）
 * @date ：Created in 2025/5/8 18:30
 * @description：
 * @modified By：
 * @version:
 */
public class Test {
    //模拟冒泡排序
    public static  void mySort(Comparable[] comparables){
        for (int i=0;i<comparables.length-1;i++)
        {
            for (int j=0;j<comparables.length-1-i;j++){
                if (comparables[j].compareTo(comparables[j+1])>0){
                    Comparable tmp=comparables[j];
                    comparables[j]=comparables[j+1];
                    comparables[j+1]=tmp;
                }
            }
        }
    }

    public static void main(String[] args) {
       Student student1= new Student("zhangsan",10);
       Student student2= new Student("zhangsan",10);
        System.out.println(student1.equals(student2));
    }
    public static void main2(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student("zhangsan",10);
        students[1]=new Student("lisi",19);
        students[2]=new Student("wangwu",10);
        System.out.println("排序前-----");
        System.out.println(Arrays.toString(students));
        mySort(students);
        System.out.println("排序后-------");
        System.out.println(Arrays.toString(students));
    }
    public static void main3(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student("zhangsan",10);
        students[1]=new Student("lisi",10);
        students[2]=new Student("wangwu",18);
        System.out.println("排序前-----");
        System.out.println(Arrays.toString(students));
        NameComparator nameComparator=new NameComparator();
        Arrays.sort(students,nameComparator);
        System.out.println("排序后-------");
      //  Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }
}